package com.wangsh.projDemo.util;

import java.util.Date;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Callable;

import com.wangsh.projDemo.common.util.ConstatFinalUtil;

/**
 * 多线程的工具类
 * 
 * @author wangsh
 *
 */
public class ServiceCallableUtil implements Callable<Object>
{
	//操作类型
	private String operType ;
	// 存储参数的map
	private Map<String, Object> paramsMap;
	
	/**
	 * 多线程调用函数
	 */
	@Override
	public Object call() throws Exception
	{
		try
		{
			String thid = UUID.randomUUID().toString().replaceAll("-", "");
			Date createTime = new Date();
			paramsMap.put("createTime", createTime);
			paramsMap.put("thid", thid);
			//1是开始,0是停止
			paramsMap.put("status", "1");
			ConstatFinalUtil.THREAD_MAP.put(thid, paramsMap);
			
			ConstatFinalUtil.SYS_LOGGER.info(thid + "-----线程池开始-----");
			if("findFaceBookCookie".equalsIgnoreCase(operType))
			{
			}
			
			//将线程移除掉
			ConstatFinalUtil.THREAD_MAP.remove(thid);
			ConstatFinalUtil.SYS_LOGGER.info(thid + "-----线程池结束-----");
		} catch (Exception e)
		{
			ConstatFinalUtil.SYS_LOGGER.error("启动多线程报错了;条件:{}", paramsMap + ";operType:" + this.operType,e);
		}
		return Long.valueOf("0");
	}

	public void setParamsMap(Map<String, Object> paramsMap)
	{
		this.paramsMap = paramsMap;
	}

	public void setOperType(String operType)
	{
		this.operType = operType;
	}
}
